package com.aloda.ojjudge.pojo.enums;

/**
 * 代码沙箱类型枚举
 * @Author aloda
 * @Date 2025/4/29 15:18
 */
public enum CodeSandboxEnum {

    // 示例沙箱、远程沙箱、第三方沙箱
    EXAMPLE("示例沙箱", 0),
    REMOTE("远程沙箱", 1),
    THIRD_PARTY("第三方沙箱", 2);

    private final String text;

    private final Integer value;

    CodeSandboxEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static java.util.List<Integer> getValues() {
        return java.util.Arrays.stream(values()).map(item -> item.value).collect(java.util.stream.Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static CodeSandboxEnum getEnumByValue(Integer value) {
        if (org.springframework.util.ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (CodeSandboxEnum anEnum : CodeSandboxEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }
}
